<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<title>DataGrid Complex Toolbar - jQuery EasyUI Demo</title>
	<script type="text/javascript" src="__PUBLIC__/Resourse/js/jquery-1.8.0.min.js"></script>
	<script type="text/javascript" charset="UTF-8" src="__PUBLIC__/Resourse/js/jquery.cookie.js"></script>
	<link rel="stylesheet" type="text/css" href="__PUBLIC__/Resourse/themes/default/easyui.css" id="easyuiTheme">
	<script type="text/javascript" charset="UTF-8" src="__PUBLIC__/Resourse/js/changeEasyuiTheme.js"></script>
	<link rel="stylesheet" type="text/css" href="__PUBLIC__/Resourse/themes/icon.css">
	<script type="text/javascript" src="__PUBLIC__/Resourse/js/jquery.easyui.min.js"></script>
	<style type="text/css">  
        #studentfm{  
            margin:0;  
            padding:10px 10px 30px 5px;  
       }  
       .ftitle{  
            font-size:14px;  
            font-weight:bold;  
            padding:5px 0;  
            margin-bottom:10px;  
            border-bottom:1px solid #ccc;  
        }  
       .fitem{  
            margin-bottom:0px;  
       }  
        .fitem label{             
            width:80px;  
        }
        .formText {
        	border-left:none; border-right:none; border-top:none; border-bottom: 1 solid #000000;
        	width : 80px;
        } 
        .combo {
		  border-color: rgb(233, 230, 230);
		  background-color: #ffffff;
		} 
		.panel-header,
		.panel-body {
		  border-color: rgb(222, 223, 224);
		}
    </style>  
    <script type="text/javascript">  
      var url; 
      var orderUrl;
      var orderDetailUrl;
      //添加报名单
      function newOrder(){  
            $('#dlg_order').dialog('open').dialog('setTitle','添加报名信息');  
           	$('#orderfm').form('clear');  
           	orderUrl = '__URL__/addOrder/';  
            
            //加载报名单明细
            $('#order_details_data').datagrid('loadData', { total: 0, rows: [] });
       } 
      
      
      //修改报名单
      function editOrder(){  
    	    var rows = $('#order_list_data').datagrid('getSelections'); 
            if (rows.length == 1){  
               $('#dlg_order').dialog('open').dialog('setTitle','修改报名单');  
               $('#orderfm').form('load',rows[0]);  
                           
               //加载报名单明细
               var queryParams = $('#order_details_data').datagrid('options').queryParams; 
               queryParams.LS_DDBH = $("#Id").val();
               $('#order_details_data').datagrid('reload'); 
               
               orderUrl = '__URL__/saveOrder?id=' + rows[0].Id;  
           }  
       }
      
      //添加课程
      function addOrderDetail(){
          $('#dlg_order_detail').dialog('open').dialog('setTitle','添加课程');  
          $('#order_detail_fm').form('clear');  
      }
      
      //修改课程
      function editOrderDetail(){         
          var rows = $('#order_details_data').datagrid('getSelections'); 
          if(rows.length > 0){
        	  $('#dlg_order_detail').dialog('open').dialog('setTitle','修改课程'); 
        	  $('#order_detail_fm').form('load',rows[0]); 
          }       
          //$('#order_detail_fm').form('clear');  
      }
      
      //删除课程
      function destroyOrderDetail(){         
          var rows = $('#order_details_data').datagrid('getSelections'); 
          if(rows){
	          	$.messager.defaults.ok = "确定"; //改变默认按钮文字
	        	$.messager.defaults.cancel = "取消"; //改变默认按钮文字
	            $.messager.confirm('确认','确认要删除吗?',function(r){             	
	               if (r){              	   
	             	  for(var i = 0;i<rows.length;i++){
	                	  var index = $('#order_details_data').datagrid('getRowIndex', rows[i]);  
	                	  $('#order_details_data').datagrid('deleteRow',index); 
	            	  } 
	                }  
	            }); 
          }       
      }
      
      //保存课程到grid     
      function saveOrderDetail(){
    	 $('#order_details_data').datagrid('appendRow',{    		
			LS_KCBH: $("#LS_KCMC").combobox('getValue'),
			LS_KCMC: $("#LS_KCMC").combobox('getText'),
			LS_KCJG: $('#LS_KCJG').val(),
			LS_KCLX: $('#LS_KCLX').val(),
			LS_SL: $('#LS_SL').val(),
			LS_JSBH: $("#LS_JSMC").combobox('getValue'),
			LS_JSMC: $("#LS_JSMC").combobox('getText'),
			LS_ZK: $('#LS_ZK').val(),
			LS_YFJE: $('#LS_YFJE').val(),  			
    	  });
    	  $('#order_detail_fm').form('clear'); 
      }
       
       
       //订单pagebar
       function orderDetailpageBar() {
           var p = $('#order_details_data').datagrid('getPager');  
           $(p).pagination({  
               pageSize: 10,//每页显示的记录条数，默认为10  
               pageList: [5,10,20],//可以设置每页记录条数的列表  
               beforePageText: '第',//页数文本框前显示的汉字  
               afterPageText: '页    共 {pages} 页',  
               displayMsg: '当前显示 {from} - {to} 条记录   共 {total} 条记录',  
           }); 
       }

       //保存报名单
       function saveOrder(){
    	   var rows = $('#order_details_data').datagrid('getRows');
    	   alert(rows)
    	   console.log(rows)
    	   var DD_PPMC = '';
    	   if(rows.length!=0){ //拼接课程名称，逗号分隔
               for(var i=0;i<rows.length;i++){
            	   DD_PPMC += rows[i].LS_KCMC + ',';
               }
               DD_PPMC = DD_PPMC.substring(0, DD_PPMC.length-1);
    	   }
    	   var DD_KHBH = $('#DD_KHBH').val();
    	   var DD_KHMC = $('#DD_KHMC').val();
    	   var DD_FP = $('#DD_FP').val();
    	   var DD_FPTT= $('#DD_FPTT').val();
    	   var DD_FPNN = $('#DD_FPNN').val();
    	   var DD_SL= $('#DD_SL').val();
    	   var DD_YF= $('#DD_YF').val();
    	   var DD_SF = $('#DD_SF').val();
    	   var DD_ZJE = $('#DD_ZJE').val();
    	   var DD_ZK = $('#DD_ZK').val();
    	   var DD_SYYHQ = $('#DD_SYYHQ').val();
    	   var DD_ZFFS = $("#DD_ZFFS").combobox('getValue');
    	   var DD_ZD = $("#DD_ZD").combobox('getValue');
    	   var DD_DDZT = $("#DD_DDZT").combobox('getValue');
    	   var DD_CJSJ = $('#DD_CJSJ').datebox('getValue');
    	   var DD_TJR = $('#DD_TJR').val();
    	   var DD_BZ = $('#DD_BZ').val();
		   var courseList = rows;
    	   var postParams = {DD_KHBH:DD_KHBH,
    			   			 DD_KHMC:DD_KHMC,
    			   			 DD_FP:DD_FP,
    			   			 DD_FPTT:DD_FPTT,
    			   			 DD_FPNN:DD_FPNN,
    			   			 DD_PPMC:DD_PPMC,
    			   			 DD_SL:DD_SL,
    			   			 DD_YF:DD_YF,
    			   			 DD_SF:DD_SF,
    			   			 DD_ZJE:DD_ZJE,
    			   			 DD_ZK:DD_ZK,
    			   			 DD_SYYHQ:DD_SYYHQ,
    			   			 DD_ZFFS:DD_ZFFS,
    			   			 DD_ZD:DD_ZD,
    			   			 DD_DDZT:DD_DDZT,
    			   			 DD_CJSJ:DD_CJSJ,
    			   			 DD_TJR:DD_TJR,
    			   			 DD_BZ:DD_BZ,
    			   			 courseList:courseList
    			   			};   	   
           $.post(orderUrl,postParams,function(result){  
               if (result.success){  
                  $('#order_list_data').datagrid('reload');    // reload the order data  
               } else {  
                  $.messager.show({   // show error message  
                       title: '错误',  
                       msg: result.errorMsg  
                   });  
              }  
          },'json');  
        }   
       
       //删除报名单
        function destroyOrder(){  
           var rows = $('#order_list_data').datagrid('getSelections');  
           var ids = '';
           for(var i=0;i<rows.length;i++){
        	   ids += rows[i].Id + ',';
           }
           ids = ids.substring(0, ids.length-1);//获取所有要删除的ID
            if (rows.length!=0){  
            	$.messager.defaults.ok = "确定"; //改变默认按钮文字
            	$.messager.defaults.cancel = "取消"; //改变默认按钮文字
                $.messager.confirm('确认','确认要删除吗?',function(r){             	
                   if (r){              	   
                      $.post('__URL__/delOrder/',{ids:ids},function(result){  
                            if (result.success){  
                               $('#order_list_data').datagrid('reload');    // reload the user data  
                            } else {  
                               $.messager.show({   // show error message  
                                    title: '错误',  
                                    msg: result.errorMsg  
                                });  
                           }  
                       },'json');  
                    }  
                });  
            }  
       }         
       
       $(window).resize(function(){  
        	$('#order_list_data').datagrid('resize');  
       });   
       
       //设置分页
       $(function(){
    	 	//设置分页控件  
           var p = $('#order_list_data').datagrid('getPager');  
           $(p).pagination({  
               pageSize: 10,//每页显示的记录条数，默认为10  
               pageList: [10,20,30],//可以设置每页记录条数的列表  
               beforePageText: '第',//页数文本框前显示的汉字  
               afterPageText: '页    共 {pages} 页',  
               displayMsg: '当前显示 {from} - {to} 条记录   共 {total} 条记录',  
           }); 
       });
       
    </script>  
</head>
<body style="overflow: hidden; height:auto;margin:0">
	<table id ="order_list_data" class="easyui-datagrid" style="overflow: hidden;height:auto;margin:0"
			data-options="title:'报名单列表',border:true,striped:true,nowrap:false,fit:true,rownumbers:true,pagination:true,singleSelect:false,url:'__URL__/readOrder/',toolbar:'#tb'" >
		<thead>
			<tr>
				<th data-options="field:'checkbox',checkbox:true" id="checkedAll"></th>	
				<th data-options="field:'Id',fitColumns: true,hidden:true">ID</th>
				<th data-options="field:'DD_BH',fitColumns: true,width:120,align:'center'">报名单号</th>
				<th data-options="field:'DD_KHBH',fitColumns: true,width:120,align:'center'">学生编号</th>
				<th data-options="field:'DD_KHMC',fitColumns: true,width:80,align:'center'">学生名称</th>
				<th data-options="field:'DD_PPMC',fitColumns: true,width:80,align:'center'">课程名称</th>
				<th data-options="field:'DD_SL',fitColumns: true,width:80,align:'center'">课程数量</th>
				<th data-options="field:'DD_ZJE',itColumns: true,width:80,align:'center'">总金额 </th>
				<th data-options="field:'DD_ZFFS',itColumns: true,width:80,align:'center'">支付方式</th>
				<th data-options="field:'DD_ZD',itColumns: true,width:100,align:'center'">订单来源</th>
				<th data-options="field:'DD_YF',itColumns: true,width:80,align:'center'">应付 </th>
				<th data-options="field:'DD_SF',itColumns: true,width:80,align:'center'">实付</th>
				<th data-options="field:'DD_ZK',itColumns: true,width:80,align:'center'">折扣金额</th>
				<th data-options="field:'DD_CJSJ',itColumns: true,width:80,align:'center'">时间</th>
				<th data-options="field:'DD_CJRMC',itColumns: true,width:80,align:'center'">创建人</th>
				<th data-options="field:'DD_DDZT',itColumns: true,width:80,align:'center'">状态</th>
			</tr>
		</thead>
	</table>
	<div id="tb" style="padding:0px;height:auto">
		<div style="margin-bottom:0px">
		<table>
			<tr>
				<td><a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-add" plain="true" onclick="newOrder()">添加</a>  </td>
				<td><a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-edit" plain="true" onclick="editOrder()">修改</a> </td>
				<td><a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-remove" plain="true" onclick="destroyOrder()">删除</a></td>
			</tr>  
			</table>
		</div>
	</div>
	
	<!-- 报名单信息 -->
	<div id="dlg_order" class="easyui-dialog" style="width:920px;height:700px;padding:10px 20px"  
            closed="true" buttons="#dlg_order_buttons">  
        <div class="ftitle">报名信息</div>  
        <form id="orderfm" method="post" novalidate>  
        <input name="DD_BH" id="DD_BH" class="easyui-validatebox formText" type="hidden">
        <input name="Id" id="Id" class="easyui-validatebox formText" type="hidden">    
            <table cellspacing="10">
            <tr>
	           <!--<td>            
		             <div class="fitem">  
		                <label>报名单号:</label>  
		                <input name="DD_BH" class="easyui-validatebox formText">      
		            </div>   
	            </td>-->
	            <td>           
		             <div class="fitem">  
		                <label>学生学号:</label>  
		               <input name="DD_KHBH" class="formText" id= "DD_KHBH">  
		            </div>  
	            </td>
	            <td>            
		            <div class="fitem">  
		                <label>学生姓名:</label>  
		                <input name="DD_KHMC" id="DD_KHMC" class="easyui-validatebox formText" >  
		            </div>    
	            </td>
	            <td colspan ="3">            
		           <div class="fitem">  
		                <label>发票:</label>  
		                <INPUT type="radio" name="DD_FP" id= "DD_FP" checked="checked" value="1">开
						<INPUT type="radio" name="DD_FP" id= "DD_FP" value="0">不开
		           </div> 
	            </td>              
            </tr>  
            <tr>
            <td colspan="5">           
		           <div class="fitem">  
		                <label>发票抬头:</label>  
						<input name="DD_FPTT" id="DD_FPTT" class="easyui-validatebox formText"  style ="width:400px"> 
		           </div>
	            </td>                                 
            </tr>  
            <tr>
            	<td colspan="5">           		
		           <div class="fitem">  
		                <label>发票内容:</label>  
						<input name="DD_FPNN" id="DD_FPNN" class="easyui-validatebox formText" style ="width:712px"> 
		           </div>   
	            </td> 
            </tr> 

            <tr>  
               <td>           
		           <div class="fitem">  
		                <label>课程数量:</label>  
						<input name="DD_SL" id="DD_SL" class="easyui-validatebox formText" >
		           </div>
	            </td>
                <td>           
		            <div class="fitem">
		                <label>应&nbsp;&nbsp;&nbsp;&nbsp;付:</label>  
						<input class="easyui-validatebox formText"  id ="DD_YF" name="DD_YF">
		           </div>
	            </td>
	            <td>            		
		            <div class="fitem">
		                <label>实&nbsp;&nbsp;&nbsp;&nbsp;付:</label>  
						<input class="easyui-validatebox formText"  id="DD_SF" name="DD_SF">
		           </div> 
	            </td>	
	            <td>           
		           <div class="fitem">  
		                <label>总&nbsp;金&nbsp;额:</label>  
						<input name="DD_ZJE" id="DD_ZJE" class="easyui-validatebox formText" >
		           </div>  
	            </td>
	             <td>           
		            <div class="fitem">
		                <label>折扣金额:</label>  
						<input class="easyui-validatebox formText"  id="DD_ZK" name="DD_ZK">
		           </div>   
	            </td>
            </tr>
            <tr>
            	<td>            		
		            <div class="fitem">  
		                <label>优惠编号:</label>  
		                <input name="DD_SYYHQ" id="DD_SYYHQ" class="easyui-validatebox formText" >  
		            </div> 
	            </td>
	            <td>           
		           <div class="fitem">  
		                <label>支付方式:</label>  
						<input class="easyui-combobox formText" id="DD_ZFFS" name="DD_ZFFS" data-options="valueField:'ITEM_KEY',textField:'ITEM_VALUE',url:'__URL__/schoolList?type=7'"> 
		           </div>
	            </td> 
            	<td>           
		           <div class="fitem">  
		                <label>订单来源:</label>  
						<input class="easyui-combobox formText" id="DD_ZD" name="DD_ZD" 
						data-options="valueField:'ITEM_KEY',textField:'ITEM_VALUE',url:'__URL__/schoolList?type=1'">
		           </div>
	            </td>
	            <td>            
		           <div class="fitem">  
		                <label>订单状态:</label>  
						<input class="easyui-combobox formText" id="DD_DDZT" name="DD_DDZT" data-options="valueField:'ITEM_KEY',textField:'ITEM_VALUE',url:'__URL__/schoolList?type=6'">
		           </div>
	            </td>	            
                <td>            		
		            <div class="fitem">
		                <label>订单日期:</label>  
						<input  class="easyui-datebox formText" name="DD_CJSJ" id="DD_CJSJ">
		           </div>  
	            </td>

            </tr>      
            <tr>	
	            <td colspan="1">            		
		            <div class="fitem">
		                <label>推&nbsp;荐&nbsp;人:</label>  
						<input class="easyui-validatebox formText"  name="DD_TJR" id="DD_TJR">
		            </div> 
	            </td>  	
	            <td colspan="4">           
		           <div class="fitem">
		                <label>备&nbsp;&nbsp;&nbsp;&nbsp;注:</label>
		                <input class="easyui-validatebox formText"  name="DD_BZ" id="DD_BZ" style ="width:400px">
		               <!-- <textarea name="DD_BZ" style="height:60px;width:200px"></textarea> --> 
		            </div>  
	            </td>	
	       </tr> 
	        <tr>
            	<td colspan="5"> 
            	<div class="ftitle">报名课程明细</div>
            	<div id="tb_orderDetail" style="padding:0px;height:auto;background:white">
				<div style="margin-bottom:0px">
				<table>
					<tr>
						<td><a href="javascript:void(0)" class="easyui-linkbutton"  iconCls="icon-add" plain="true" onclick="addOrderDetail()">添加课程</a>  </td>
						<td><a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-edit" plain="true" onclick="editOrderDetail()">修改课程</a> </td>
						<td><a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-remove" plain="true" onclick="destroyOrderDetail()">删除课程</a></td>
					</tr>  
					</table>
				</div>
			</div>
            	
            	</td>
            
            </tr>
            <tr>
	            <td colspan="5">
		       		<table id ="order_details_data" class="easyui-datagrid" style="overflow: hidden;height:auto;margin:0"
					data-options="rownumbers:false,pagination:false,singleSelect:false,url:'__URL__/readOrderDetails/'" >
						<thead>
						<tr>
							<th data-options="field:'LS_KCBH',fitColumns: true,width:120,align:'center'">课程编号</th>
							<th data-options="field:'LS_KCMC',fitColumns: true,width:80,align:'center'">课程名称</th>
							<th data-options="field:'LS_KCJG',fitColumns: true,width:80,align:'center'">课程价格</th>
							<th data-options="field:'LS_KCLX',fitColumns: true,width:80,align:'center'">课程类型</th>
							<th data-options="field:'LS_JSBH',itColumns: true,width:100,align:'center'">教室编号</th>
							<th data-options="field:'LS_JSMC',itColumns: true,width:120,align:'center'">教室名称</th>
							<th data-options="field:'LS_ZK',itColumns: true,width:60,align:'center'">折扣</th>
							<th data-options="field:'LS_SL',itColumns: true,width:80,align:'center'">报名人数</th>
							<th data-options="field:'LS_YFJE',itColumns: true,width:80,align:'center'">应付金额</th>
						</tr>
						</thead>
					</table>
	            </td>
            </tr>                                                                  
            </table>            
        </form>  
    </div>  
    <div id="dlg_order_buttons">  
        <!-- --><a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-ok" onclick="saveOrder()">保存</a>   
       <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-cancel" onclick="javascript:$('#dlg_order').dialog('close')">关闭</a>  
    </div>
    
    
  	<!-- 报名单课程 --> 
  	 	<div id="dlg_order_detail" class="easyui-dialog" style="width:550px;height:250px;padding:10px 20px"  
            closed="true" buttons="#dlg_order_detail_buttons">  
         <form id="order_detail_fm" method="post" novalidate>  
            <table cellspacing="15">
            <tr>
	            <td>            
	                <div class="fitem">  
		                <label>课程名称:</label>  
						<input class="easyui-combobox formText" id="LS_KCMC" name="LS_KCMC" data-options="valueField:'id',textField:'text',url:'__URL__/courseList'"> 
		           </div> 
	            <td>           
		           <div class="fitem">  
		                <label>课程价格:</label>  
						<input name="LS_KCJG" class="easyui-validatebox formText" id="LS_KCJG">
		           </div>  
	            </td>	
	            <td>            
		           <div class="fitem">  
		                <label>课程类型:</label>  
						<input class="easyui-combobox formText" id="LS_KCLX" name="LS_KCLX" data-options="valueField:'id',textField:'text'"> 
		           </div>  
	            </td>            
            </tr>  
            <tr>
	            <td>            
		           <div class="fitem">  
		                <label>报名人数:</label>  
						<input name="LS_SL" class="easyui-validatebox formText" id="LS_SL" > 
		           </div> 
	            </td>
	            <td>           
		           <div class="fitem">  
		                <label>折&nbsp;&nbsp;&nbsp;&nbsp;扣:</label>  
						<input class="easyui-combobox formText" id="LS_ZK" name="LS_ZK" data-options="valueField:'id',textField:'text'"> 
		           </div>
	            </td>	
	            <td>           
		           <div class="fitem">  
		                <label>应付金额:</label>  
						<input name="LS_YFJE" class="easyui-validatebox formText" id="LS_YFJE"> 
		           </div>
	            </td>	
           		</tr> 
           		<tr>	             
	           		<td>            
			           <div class="fitem">  
			                <label>教室名称:</label>  
							<input class="easyui-combobox formText" id="LS_JSMC" name="LS_JSMC" data-options="valueField:'ITEM_KEY',textField:'ITEM_VALUE',url:'__URL__/schoolList?type=8'">
			           </div>
		            </td>  
	            </tr>                                                               
            </table>            
        </form>  
    </div>     
    <div id="dlg_order_detail_buttons">  
       <!-- --><a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-ok" onclick="saveOrderDetail()">确定</a>   
      <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-cancel" onclick="javascript:$('#dlg_order_detail').dialog('close')">取消</a>  
   </div>
</body>
</html>